1. Technical Field
The present disclosure relates to a system and method of using a general-purpose microprocessor to debug a Programmable Logic Controller (PLC), and, in particular, to a system and method of using a general-purpose microprocessor to debug a PLC, which uses a general-purpose Main Processing Unit (MPU) having no separate trace function unlike a dedicated Application-Specific Integrated Circuit (ASIC), to enable a user to interrupt a driving at a step set by the user, thereby effectively debugging the PLC.
2. Description of the Related Art
A Programmable Logic Controller (PLC) performs a function of interrupting operations of the PLC at a program step a user desires in the middle of executing a sequence program written by the user, to enable the user to check hitherto driving information, such that the user can easily detect errors in the user's program or data at a specific time point.
A personal computer (PC) performs operations of transmitting a debug command to the PLC via communications, the debug command containing a debugging interrupt step which the user may select arbitrarily, and reading various data from the PLC.
The PLC performs fundamental processing required to operate the PLC itself and, on the way of performing operations for executing compile codes, performs operations of interrupting the driving at a driving step transmitted from the PC and also resuming the driving according to instructions from the PC.
Upon receiving the interrupt step to interrupt the debugging from the PC, the PLC stores step's number of the interrupt step to interrupt the debugging in a buffer within the PLC. The PLC executes a debug check function every step when executing the user's program. The debug check function serves to determine whether a current driving step corresponds to the interrupt step stored in the buffer and allow the driving to be interrupted when the current driving step is determined to correspond to the interrupt step. The PLC having interrupted the driving at any function waits until it receives a driving resume instruction from the PC and resumes the driving from the interrupted step upon receiving the driving resume instruction.
Generally, an ASIC dedicated to the PLC is designed to include a TRACE function in H/W, wherein the TRACE function is a function of interrupting the driving at a particular step in the user's program and notifying this to the PLC.
However, the general-purpose MPU has no such a function, and hence contains an algorithm designed for the PLC to follow a debugging check routine every step. Therefore, a conventional debugging processing routine determines whether a current driving mode of the PLC is a debugging mode, interrupts the driving when the current driving mode is determined to be the debugging mode, and then waits until the next instruction is transmitted from the PC. The PLC resumes the driving from the next step of the currently interrupt step upon receiving the driving resume instruction.
A conventional debugging method executes the debugging processing routine of checking a debugging interrupt processing condition every driving step of the user's program and thus a processing time of the PLC increases for performing the branching and debug processing operations.
Further, the PLC repeatedly executes the debugging check routine not performed in the normal driving mode even when it drives in the debugging mode. Therefore, there is a possibility that unpredictable contaminant effects may occur and thus the PLC may be likely to not operate as in a driving mode.